<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
var school = {
    schoolName: "育知同创",
    address: "深圳",
    classes: [
        {
            className: "H-1704",
            students: ["李四", "张三", "王五", "志玲"]
        }, {
            className: "H-1703",
            students: ["李四1", "张三1", "王五1", "志玲1"]
        }
    ],
    getStudent : function (stuName){
        for(var clazz of this.classes){
            var students = clazz.students;
            for(var stu of students){
                if(stu == stuName){
                    return {  // 返回一个表示学生的对象
                        schoolName : this.schoolName,
                        schoolAddr : this.address,
                        className : clazz.className,
                        stuName : stuName
                    }
                }
            }
        }
    }
}

var stu = school.getStudent("李四1");
console.log(stu);
</script>
</body>
</html>
<!--
在对象的方法中使用this
 代表调用这个方法的时候使用的那个对象


-->